//
//  ShippingAdressModel.m
//  quxiangtao
//
//  Created by xbmios on 2018/9/29.
//  Copyright © 2018年 shanhaijin. All rights reserved.
//

#import "ShippingAdressModel.h"

@implementation ShippingAdressModel

+ (void)shippingAddressWithClassid:(NSString *)classID success:(HttpRequestSuccess)successBlok fail:(HttpRequestFailed)failBlock {
    
    NSString *par = [NSString stringWithFormat:@"{\"user_id\" : \"%@\", \"classid\" : \"%@\"}", [RSA encryptString:[CommonUserInfo sharedInstance].user_id publicKey:PublicKey], [RSA encryptString:classID publicKey:PublicKey]];
    
    [PPNetworkHelper POST:@"user/Address/changeAddress" parameters:@{@"json" : par} success:^(id responseObject) {
        
        NSLog(@"收货地址:%@",responseObject);
        
        NSArray *dictArr = responseObject[@"data"];
        
        NSMutableDictionary *d = [NSMutableDictionary dictionaryWithDictionary:responseObject];
        
        if (dictArr.count > 0) {
            
            // 转模型数组
            NSArray *modelArr = [ShippingAdressModel mj_objectArrayWithKeyValuesArray:dictArr];
            
            [d removeObjectForKey:@"data"];
            [d setObject:modelArr forKey:@"data"];
        }
        
        if (successBlok) {
            
            successBlok(d);
            
        }
        
    } failure:^(NSError *error) {
        
        if (failBlock) {
            
            failBlock(error);
        }
        
    }];
    
}

@end
